package com.qiaoanju.controller;

import com.qiaoanju.domain.UserDomain;
import com.qiaoanju.feign.UserFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserConsumerController {

    @Autowired
    private UserFeignClient userFeignClient;

    @GetMapping("/movie/{id}")
    public UserDomain findById(@PathVariable Long id) {
        return this.userFeignClient.findById(id);
    }

    @PostMapping("/test")
    public UserDomain testPost(UserDomain user) {
        return this.userFeignClient.postUser(user);
    }

    @GetMapping("/login")
    public UserDomain login(@RequestParam("username") String username, @RequestParam("password") String password) {
        Map<String, Object> map = new HashMap<>();
        map.put("username", "张三");
        map.put("password", "123");
        return this.userFeignClient.login(map);
    }
}
